/*
 * @Author: your name
 * @Date: 2021-05-25 16:39:15
 * @LastEditTime: 2021-05-26 14:04:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \cash-register-draft1\router.js
 */
// router.js
import { RouterMount, createRouter } from 'uni-simple-router'
import Layout from '@/layout'

const router = createRouter({

  platform: process.env.VUE_APP_PLATFORM,
  h5: {
    vueRouterDev: true, //完全使用vue-router开发 默认 false
  },
  routes: [
    // ...ROUTES,//pages.json中的配置
    {
      path: '/',
      redirect: '/home',
      component: Layout,
      children: [
        {
          path: '/home',
          name: 'Home',
          meta: {
            title: '收银台',
            icon: '../../../static/siderbar/home.png',
            acticon: '../../../static/siderbar/acthome.png',
          },
          component: () => import('@/pages/index/index'),
        },
        {
          path: '/order',
          name: 'Order',
          meta: {
            title: '交易订单',
            icon: '../../../static/siderbar/order.png',
            acticon: '../../../static/siderbar/actorder.png',
          },
          component: () => import('@/pages/order/index'),
        },
        {
          path: '/sale-channel',
          name: 'SaleChannel',
          meta: {
            title: '销售渠道',
            icon: '../../../static/siderbar/sale.png',
            acticon: '../../../static/siderbar/actsale.png',
          },
          component: () => import('@/pages/salechannel/index'),
        },
        {
          path: '/system-settings',
          name: 'SystemSettings',
          meta: {
            title: '系统设置',
            icon: '../../../static/siderbar/setting.png',
            acticon: '../../../static/siderbar/actsetting.png',
          },
          component: () => import('@/pages/system-settings/index'),
        },
        
      ],
    },
    {
			path: '/login',
			name:"Login",
			component: ()=>import('@/pages/login/index')
		},
    {
      path: '*',
      redirect: to => {
        return {
          name: 'Home',
          component: () => import('@/pages/index/index'),
        }
      },
    },
  ],
})
//全局路由前置守卫
router.beforeEach((to, from, next) => {
  next()
})
// 全局路由后置守卫
router.afterEach((to, from) => {
  // console.log('跳转结束')
})

export { router, RouterMount }
